﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace dbPoll_Application.Models
{
    public class QuestionOption
    {
        public virtual int optionID { get; set; }
        public virtual int optionNumber { get; set; }
        public virtual String answer { get; set; }
        public virtual Boolean correctCurrent { get; set; }
        public virtual Boolean correctOriginal { get; set; }
        [Required(ErrorMessage = "Points are required.")]
        [RegularExpression(@"^-?[0-9]+$", ErrorMessage = "Invalid points value.")]
        public virtual int pointsCurrent { get; set; }
        [Required(ErrorMessage = "Points are required.")]
        [RegularExpression(@"^-?[0-9]+$", ErrorMessage = "Invalid points value.")]
        public virtual int pointsOriginal { get; set; }
        public virtual IList<OptionResponse> responses { get; set; }

        public QuestionOption()
        {
            this.optionID = -1;
            this.optionNumber = -1;
            this.answer = String.Empty;
            this.correctCurrent = false;
            this.correctOriginal = false;
            this.pointsCurrent = 0;
            this.pointsOriginal = 0;
            this.responses = null;
        }

        public QuestionOption(String answer)
        {
            this.optionID = -1;
            this.optionNumber = -1;
            this.answer = answer;
            this.correctCurrent = false;
            this.correctOriginal = false;
            this.pointsCurrent = 0;
            this.pointsOriginal = 0;
            this.responses = new List<OptionResponse>();
        }

        public QuestionOption(String answer, int optionNumber)
        {
            this.optionID = -1;
            this.optionNumber = optionNumber;
            this.answer = answer;
            this.correctCurrent = false;
            this.correctOriginal = false;
            this.pointsCurrent = 0;
            this.pointsOriginal = 0;
            this.responses = new List<OptionResponse>();
        }

        public QuestionOption(int optionNumber, String answer, Boolean correctCurrent, Boolean correctOriginal, int pointsCurrent, int pointsOriginal, IList<OptionResponse> responses)
        {
            this.optionID = -1;
            this.optionNumber = optionNumber;
            this.answer = answer;
            this.correctCurrent = correctCurrent;
            this.correctOriginal = correctOriginal;
            this.pointsCurrent = pointsCurrent;
            this.pointsOriginal = pointsOriginal;
            this.responses = responses;
        }

        public QuestionOption(int optionID, int optionNumber, String answer, Boolean correctCurrent, Boolean correctOriginal, int pointsCurrent, int pointsOriginal, IList<OptionResponse> responses)
        {
            this.optionID = optionID;
            this.optionNumber = optionNumber;
            this.answer = answer;
            this.correctCurrent = correctCurrent;
            this.correctOriginal = correctOriginal;
            this.pointsCurrent = pointsCurrent;
            this.pointsOriginal = pointsOriginal;
            this.responses = responses;
        }
    }
}
